//
//  SXTMyMessageHeadView.m
//  SXT
//
//  Created by gaochar on 2017/3/18.
//  Copyright © 2017年 so. All rights reserved.
//

#import "SXTMyMessageHeadView.h"

@interface SXTMyMessageHeadView ()
/**
 * 顶部背景图片
 */
@property (nonatomic, strong) UIImageView *headBackImage;

/**
 * 登录按钮
 */
@property (nonatomic, strong) UIButton *loginBtn;

/**
 注册按钮
 */
@property (nonatomic, strong) UIButton *landingBtn;
@end

@implementation SXTMyMessageHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.headBackImage];
        [self addSubview:self.loginBtn];
        [self addSubview:self.landingBtn];
        

    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;

    
    [_headBackImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(weakSelf);
    }];
    
    [_loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.mas_centerX).offset(60);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(45, 23));
    }];
    
    [_landingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.mas_centerX).offset(-60);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(45, 23));
    }];
}

- (UIImageView *)headBackImage {
    if (!_headBackImage) {
        _headBackImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"我的背景"]];
    }
    return _headBackImage;
}

- (UIButton *)loginBtn {
    if (!_loginBtn) {
        _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_loginBtn setTitle:@"登录" forState:UIControlStateNormal];
        _loginBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
        _loginBtn.titleLabel.textColor = [UIColor whiteColor];
        _loginBtn.backgroundColor = [UIColor clearColor];
    }
    return _loginBtn;
}

- (UIButton *)landingBtn {
    if (!_landingBtn) {
        _landingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_landingBtn setTitle:@"注册" forState:UIControlStateNormal];
        _landingBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
        _landingBtn.titleLabel.textColor = [UIColor whiteColor];
        _landingBtn.backgroundColor = [UIColor clearColor];
        [_landingBtn addTarget:self action:@selector(pushLandingViewController) forControlEvents:UIControlEventTouchUpInside];
    }
    return _landingBtn;
}

- (void)pushLandingViewController {
    if (_landingBlock) {
        _landingBlock();
    }
}

@end
